﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ModemGSM
{

    public enum GroupReportEnum
    {
        None = -2,
        WaitReport = -1,
        ReceiverOk = 0,
        TemporaryErrorAllowTry = 1,
        PermanentErrorNotTry = 2,
        TemporaryErrorNotTry = 3,
    }

    public enum TypeStatusReportEnum
    {
        SendConfirmation = 0,
        ReceiverAlert = 1
    }

    public enum ActiveStatusEnum
    {

        Busy = -7,
        NoDialtone = -6,
        NoCarrier = -5,
        NoAnswer = -4,
        Disconnected = -3,
        Offline = -2,
        Error = -1,
        Ready = 0,
        Unavailable = 1,
        unknown = 2,
        Ringing = 3,
        call = 4,
        asleep = 5
    }

    public enum AnalyzerCMDEnum
    {
        Model = 1,
        LineIdentification = 2,
        IndicatorControl = 3,
        ActiveStatus = 4,
        PrefOperator = 5,
        Battery = 6,
        Sginal = 7,
        Alarms = 8,
        Clock = 9,
        ChatSet = 10,
        Phonebook = 11,
        SMSFormat = 12,
        SMSStorage = 13,
        SMSAdress = 14,
        SMSHeard = 15,
        SMSIndicator = 16,
        SMSSaveSettings = 17,
        SMSRestoreSettings = 18,
        SMSMessageService = 19,
        SMSBroadcastMessage = 20,
        SMSListMessage = 21,
        SMSReadMessage = 22,
        SMSSendMessage = 23,
        SMSSendMessageStorage = 24,
        SMSWriteMessageStorage = 25,
        SMSDeleteMessageStorage = 26
    }

    public enum StorageReadEnum
    {
        SIM = 0,
        Phone = 1
    }

    public enum NoCallEventEnum
    {
        None = -1,
        NoCarrier = 0,
        Busy = 1,
        NoDialTone = 2,
        NoAnswer = 3
    }

    public enum LocationSMS
    {
        All = 0,
        UnRead = 1,
        Read = 2,
        Unsent = 3,
        Sent = 4
    }

    public enum RepeatAlamrEnum
    {
        Once = 0,
        EveryDay = 1,
        Days = 2
    }

    [Serializable]
    public class StatusSMSReport
    {
        public TypeStatusReportEnum TypeReport { get; set; }
        public string TypeCode { get; set; }
        public string Storage { get; set; }
        public int IndexStorage { get; set; }
        public string Number { get; set; }
        public string MessageSend { get; set; }
        public DateTime? DateTimeSend { get; set; }
        public TimeSpan? TimezoneSend { get; set; }
        public DateTime? DateTimeReceiver { get; set; }
        public TimeSpan? TimezoneReceiver { get; set; }
        public int Status { get; set; }
        public GroupReportEnum GroupReport 
        {
            get
            {
                if (Status >= 0 && Status <= 31)
                    return GroupReportEnum.ReceiverOk;
                else if (Status >= 32 && Status <= 63)
                    return GroupReportEnum.TemporaryErrorAllowTry;
                else if (Status >= 64 && Status <= 95)
                    return GroupReportEnum.PermanentErrorNotTry;
                else if (Status >= 96 && Status <= 127)
                    return GroupReportEnum.TemporaryErrorAllowTry;
                else if (Status < 0)
                    return GroupReportEnum.WaitReport;
                return GroupReportEnum.None;
            }
        }
        public string MessageStatus
        {
            get 
            {
                string ret = "";
                if (Status < 0)
                {
                    ret = "Wait Report";
                }
                else if (Status == 0)
                {
                    ret = "Send Confirmed";
                }
                else if (Status == 1)
                {
                    ret = "Send Forwarded";
                }
                else if (Status == 2)
                {
                    ret = "Send Replaced";
                }
                else if (Status >= 3 && Status <= 15)
                {
                    ret = "Reserved";
                }
                else if (Status >= 16 && Status <= 31)
                {
                    ret = "Not Specific";
                }
                else if (Status == 32)
                {
                    ret = "Congestion";
                }
                else if (Status == 33)
                {
                    ret = "Busy";
                }
                else if (Status == 34)
                {
                    ret = "No Response";
                }
                else if (Status == 35)
                {
                    ret = "Service Rejected";
                }
                else if (Status == 36)
                {
                    ret = "No Quality Service";
                }
                else if (Status == 37)
                {
                    ret = "Error";
                }
                else if (Status >= 38 && Status <= 47)
                {
                    ret = "Reserved";
                }
                else if (Status >= 48 && Status <= 63)
                {
                    ret = "Not Specific";
                }
                else if (Status == 64)
                {
                    ret = "Remote Procedure Error";
                }
                else if (Status == 65)
                {
                    ret = "Incompatible Destination";
                }
                else if (Status == 66)
                {
                    ret = "Connection Rejected";
                }
                else if (Status == 67)
                {
                    ret = "Not Obtainable";
                }
                else if (Status == 68)
                {
                    ret = "No Quality Service";
                }
                else if (Status == 69)
                {
                    ret = "Interworking Not Available";
                }
                else if (Status == 70)
                {
                    ret = "Validity Period Expired";
                }
                else if (Status == 71)
                {
                    ret = "Deleted by Originating";
                }
                else if (Status == 72)
                {
                    ret = "Deleted by Administration";
                }
                else if (Status == 73)
                {
                    ret = "Service Message does not exist";
                }
                else if (Status == 73)
                {
                    ret = "Service Message does not exist";
                }
                else if (Status >= 74 && Status <= 79)
                {
                    ret = "Reserved";
                }
                else if (Status >= 80 && Status <= 95)
                {
                    ret = "Not Specific";
                }
                else if (Status == 96)
                {
                    ret = "Congestion";
                }
                else if (Status == 97)
                {
                    ret = "Busy";
                }
                else if (Status == 98)
                {
                    ret = "No Response";
                }
                else if (Status == 99)
                {
                    ret = "Service Rejected";
                }
                else if (Status == 100)
                {
                    ret = "No Quality Service";
                }
                else if (Status == 101)
                {
                    ret = "Error";
                }
                else if (Status >= 102 && Status <= 111)
                {
                    ret = "Reserved";
                }
                else if (Status >= 112 && Status <= 127)
                {
                    ret = "Not Specific";
                }
                return ret;
            }
        }
    }

    [Serializable]
    public class SMSService
    {
       public int[] GSMmodes { get; set; }
       public int GSMmode { get; set; }
       public bool GSMmt { get; set; }
       public bool GSMmo { get; set; }
       public bool GSMbm { get; set; }

    }

    [Serializable]
    public class PortFound
    {
        public string COMPort { get; set; }
        public string Model { get; set; }
        public override string ToString()
        {
            return COMPort;
        }
    }

    [Serializable]
    public class ModelATCommands
    {
        public ModelATCommands()
        {
            ModelCMD = false;
            LineIdentificationCMD = false;
            IndicatorControlCMD = false;
            ActiveStatusCMD = false;
            PreferredOperatorCMD = false;
            BatteryLevelCMD = false;
            SignalQualityCMD = false;
            AlarmCMD = false;
            ClockCMD = false;
            CharSetsCMD = false;
            PhoneBookCMD = false;
            SMSFormatCMD = false;
            SMSStoragesCMD = false;
            SMSAdressServiceCMD = false;
            SMSShowHeadCMD = false;
            SMSConfigIndicationsCMD = false;
            SMSSaveSettingsCMD = false;
            SMSRestoreSettingsCMD = false;
            SMSMessageServiceCMD = false;
            SMSBroadcastMessageCMD = false;
            SMSListMessageCMD = false;
            SMSReadMessageCMD = false;
            SMSSendMessageCMD = false;
            SMSSendMessageStorageCMD = false;
            SMSWriteMessageStorageCMD = false;
            SMSDeleteMessageStorageCMD = false;
    }
        public bool ModelCMD { get; set; }
        public bool LineIdentificationCMD { get; set; }
        public bool ClockCMD { get; set; }
        public bool BatteryLevelCMD { get; set; }
        public bool IndicatorControlCMD { get; set; }
        public bool ActiveStatusCMD { get; set; }
        public bool SignalQualityCMD { get; set; }
        public bool PreferredOperatorCMD { get; set; }
        public bool AlarmCMD { get; set; }
        public bool CharSetsCMD { get; set; }
        public bool PhoneBookCMD { get; set; }
        public bool SMSFormatCMD { get; set; }
        public bool SMSStoragesCMD { get; set; }
        public bool SMSAdressServiceCMD { get; set; }
        public bool SMSShowHeadCMD { get; set; }
        public bool SMSConfigIndicationsCMD { get; set; }
        public bool SMSSaveSettingsCMD { get; set; }
        public bool SMSRestoreSettingsCMD { get; set; }
        public bool SMSMessageServiceCMD { get; set; }
        public bool SMSBroadcastMessageCMD { get; set; }
        public bool SMSListMessageCMD { get; set; }
        public bool SMSReadMessageCMD { get; set; }
        public bool SMSSendMessageCMD { get; set; }
        public bool SMSSendMessageStorageCMD { get; set; }
        public bool SMSWriteMessageStorageCMD { get; set; }
        public bool SMSDeleteMessageStorageCMD { get; set; }
    }

    [Serializable]
    public class SMSStorage
    {
        public int ID { get; set; }
        public LocationSMS Location{ get; set; }
        public string Message { get; set; }
        public string Number { get; set; }
        public string PhoneBookName { get; set; }
        public DateTime? DateTime { get; set; }
        public TimeSpan? TimeZone { get; set; }
    }

    [Serializable]
    public class StoragesSMS
    {
        public StoragesSMS()
        {
            StoReadDelete = new string[] { "" };
            StoWriteSend = new string[] { "" };
            StoReceiver = new string[] { "" };
            ReadDelete = "";
            RangerReadDelete = new RangerValue();
            WriteSend = "";
            RangerWriteSend = new RangerValue();
            Receiver = "";
            RangerReceiver = new RangerValue();
        }

        public string[] StoReadDelete { get; set; }
        public string[] StoWriteSend { get; set; }
        public string[] StoReceiver { get; set; }

        public string ReadDelete { get; set; }
        public RangerValue RangerReadDelete { get; set; }

        public string WriteSend { get; set; }
        public RangerValue RangerWriteSend { get; set; }

        public string Receiver { get; set; }
        public RangerValue RangerReceiver { get; set; }

    }

    [Serializable]
    public class LineIdentification 
    {
        public bool? Provisioned { get; set; }
        public bool Enabled { get; set; }
    }

    [Serializable]
    public class PhoneStorage
    {
        public int Index { get; set; }
        public string Name { get; set; }
        public int Type { get; set; }
        public string Number { get; set; }
    }

    [Serializable]
    public class PhoneBookMaxLength
    {
        public int Name { get; set; }
        public int Number { get; set; }
    }

    [Serializable]
    public class RangerValue
    {
        public RangerValue()
        {
            Min = 0;
            Max = 0;
            value = 0;
        }
        public int Min { get; set; }
        public int Max { get; set; }
        public int value { get; set; }
    }

    [Serializable]
    public class GSMIndicator
    {
        public GSMIndicator()
        {
            Battchg = new RangerValue();
            Signal = new RangerValue();
            Service = new RangerValue();
            Message = new RangerValue();
            Call = new RangerValue();
            Roam = new RangerValue();
            Vox = new RangerValue();
            SMSFull = new RangerValue();
        }
        public RangerValue Battchg { get; set; }
        public RangerValue Signal { get; set; }
        public RangerValue Service { get; set; }
        public RangerValue Call { get; set; }
        public RangerValue Roam { get; set; }
        public RangerValue Vox { get; set; }
        public RangerValue Message { get; set; }
        public RangerValue SMSFull { get; set; }
    }

    [Serializable]
    public class GSMAlarm
    {
        public int Index { get; set; }
        public RepeatAlamrEnum Repeat { get; set; }
        public bool Sun { get; set; }
        public bool Mon { get; set; }
        public bool Tus { get; set; }
        public bool Wed { get; set; }
        public bool Thu { get; set; }
        public bool Fri { get; set; }
        public bool Sat { get; set; }
        public int Hours { get; set; }
        public int Minutes { get; set; }
    }

    [Serializable]
    public class AutoDetectEventArgs : EventArgs
    {
        public AutoDetectEventArgs(string p)
        {
            PortName = p;
        }
        public string PortName { get; set; }
    }

    [Serializable]
    public class SmsReportEventArgs : EventArgs
    {
        public SmsReportEventArgs(StatusSMSReport r)
        {
            Report = r;
        }
        public StatusSMSReport Report { get; set; }
    }

    [Serializable]
    public class RingEventArgs : EventArgs
    {
        public RingEventArgs(string n)
        {
            Number = n;
        }
        public string Number { get; set; }
    }

    [Serializable]
    public class NoCallEventArgs : EventArgs
    {
        public NoCallEventArgs(NoCallEventEnum nc)
        {
            status = nc;
        }
        public NoCallEventEnum status { get; set; }
    }
}
